package com.community.web.controller.dept;
import com.community.common.core.controller.BaseController;
import com.community.common.core.domain.AjaxResult;
import com.community.common.core.page.TableDataInfo;
import com.community.domain.DeptEntity;
import com.community.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/dept")
public class DeptController extends BaseController {
    @Autowired
    private DeptService deptService;
    @PreAuthorize("@ss.hasPermi('dept:dept:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeptEntity dept)
    {
        startPage();
        List<DeptEntity> list = deptService.selectDeptList(dept);
        return getDataTable(list);
    }
    @PreAuthorize("@ss.hasPermi('dept:dept:add')")
    @PostMapping("/addDept")
    public AjaxResult addServeType(@RequestBody DeptEntity s)
    {

        return toAjax(deptService.addDept(s));
    }
    @PreAuthorize("@ss.hasPermi('dept:dept:edit')")
    @PutMapping("/updateDept")
    public AjaxResult updateServeType(@Validated @RequestBody DeptEntity s)
    {

        return toAjax(deptService.updateDept(s));
    }
    @PreAuthorize("@ss.hasPermi('dept:dept:remove')")
    @DeleteMapping("{deptId}")
    public AjaxResult deleteDept(@PathVariable int deptId)
    {
        return toAjax(deptService.deleteDept(deptId));
    }
}
